<template>
  <div>
    <h2>Home</h2>
    <div>
      <h2>声明式路由(push)</h2>
      <router-link to="/home/course" active-class="aa" tag="button">Course</router-link>
      <router-link :to="{name:'game'}">Game</router-link>
      <router-link :to="{path:'/home/news'}">News</router-link>
    </div>
    <hr>
    <div>
      <h2>声明式路由(replace)</h2>
      <router-link to="/home/course" active-class="aa" tag="button" replace>Course</router-link>
      <router-link :to="{name:'game'}" replace>Game</router-link>
      <router-link :to="{path:'/home/news'}" replace>News</router-link>
    </div>
    <hr>
    <div>
      <h2>编程式路由(push)</h2>
      <button @click="$router.push('course')">Course</button>
      <button @click="$router.push('/home/game')">Game</button>
      <button @click="$router.push({name:'news'})">News</button>
    </div>
    <hr>
    <div>
      <h2>编程式路由(replace)</h2>
      <button @click="$router.replace('course')">Course</button>
      <button @click="$router.replace('/home/game')">Game</button>
      <button @click="$router.replace({name:'news'})">News</button>
    </div>
    <hr>
    <div>
      <h2>历史记录</h2>
      <button @click="$router.back()">前进</button>
      <button @click="$router.forward()">后退</button>
      <button @click="$router.go('-2')">后退两步</button>
    </div>
    <hr>
    <!-- include 指定缓存哪些路由
         exclude 指定不缓存哪些路由
     -->
    <keep-alive :exclude='["Course","Game"]'>
      <router-view></router-view>
    </keep-alive>
  </div>
</template>

<script>
  export default {
    name:'Home'
  }
</script>

<style scoped>
  a{
    margin: 0 10px;
  }
  .router-link-active{
    color: chartreuse;
  }
  .aa{
    color: hotpink;
  }
</style>